import { request } from '../http';

export function checkAuthState(code: string) {
  return request.post('/api/auth/oauthLogin', { MiniCode: code });
}

export function decryptPhoneNumber(code: string) {
  return request.post('/api/auth/getPhoneNumber', { MiniCode: code });
}

export function sendPhoneCode(phone: string, countryCode: string) {
  return request.post('/api/member/SendPhoneCode', { phone, area_no: countryCode });
}

export function sendEmailCode(email: string) {
  return request.post('/api/member/SendEmailCode', { email });
}

type BindPhoneNumberPayload = {
  bindType: string;
  authId: string;
  phone: string;
  area_no: string;
  source: string;
  referrer: number;
  code: string;
};

export function bindPhoneNumber(payload: BindPhoneNumberPayload) {
  return request.post('/api/member/bindLogin', payload);
}

export function PhoneLogin(payload: object) {
  return request.post('/api/member/login', payload);
}

export function GetAppConfig(payload: object) {
  return request.post('/api/getAppConfig', payload);
}
